<?php
require_once(LIRBARY_DIR."db.php");
define('GET_USER_INFO', "");
class Character
{
    public function getInfo($id)
    {
        $sql = "select name, level, score, totalscore, wincount, losecount, coin, nickname, icon, id from tbl_user where id='".$id."'";
        return DbExecutor::getInstance()->get($sql);
    }
    
    /*
        *$params =array("name"=>array("op"=>set, "value"=>''));
        *
        *
    */
    public function updateInfo($id, $params)
    {
        $sqls=array();
        foreach($params as $name => $param)
        {
            if($param["op"] == "set")
            {
                $sqls[] = $name . "=" . "'" . $param["value"] . "'";
            }
            else
            {
                $sqls[] = $name . "=" . $name . "+" . "'" . $param["value"]. "'";
            }
        }
        $sql = "update tbl_user set " . implode(",", $sqls) . " where id='" . $id . "'";
        return DbExecutor::getInstance()->get($sql);
    }
    
}
?>
